# -*- coding = utf-8 -*-
# @Time    : 2025/3/28 下午7:41
# @Author  : yqk
# @File    : 多线程.py
# @Software: PyCharm

import threading
import time


def singing(name, delay):
    print(f'{name}开始唱歌')
    time.sleep(delay)
    print(f'{name}结束唱歌')

def dancing(name, delay):
    print(f'{name}开始跳舞')
    time.sleep(delay)
    print(f'{name}结束跳舞')

def single_thread():
    singing('小明', 2)
    dancing('小红', 3)

def multi_thread():
    task = []
    thread1 = threading.Thread(target=singing, args=('小明', 2))
    thread1.start()
    for i in range(3):
        thread2 = threading.Thread(target=dancing, args=('小红', 3))
        thread2.start()
        task.append(thread2)
    task.append(thread1)
    for t in task:
        t.join()

if __name__ == '__main__':
    st_time = time.time()
    multi_thread()
    end_time = time.time()
    print(f'单线程耗时：{end_time - st_time}')